<h2>Настройки плагина</h2>
<script type="text/javascript">
    $(document).ready(function(){

        $("div.main-text table tr:not(:first):odd").css("background", "#eee");    


        $(".install_plugin").click(
        function ()
        {
            var main = $("#main");
            var load = $("#load");

            load.fadeIn('slow');

            $.ajax({
                type: "POST", url: "admin.php?page=plugins&type=ajax&action=install&name="+this.id, data: "",

                complete: function(data)
                {
                    result = data.responseText;
                    main.html( result );
                    load.fadeOut('slow');
                }
            });
        }
        );          

        $(".remove_plugin").click(
        function ()
        {
            var main = $("#main");
            var load = $("#load");

            load.fadeIn('slow');

            $.ajax({
                type: "POST", url: "admin.php?page=plugins&type=ajax&action=remove&name="+this.id, data: "",

                complete: function(data)
                {
                    result = data.responseText;
                    main.html( result );
                    load.fadeOut('slow');
                }
            });
        }
        );             



    });

</script>     

<?php

    m::c('form');   
    $plugin_array = p::get_list();
    $name =  @$_GET['name'];

    if ( $name )
    {

        echo 'Установлен:';
        if ( p::$info [ $name ]['installed']  == 1 )
        {
            echo 'да';
        }
        else
        {
            echo 'нет';
        }

        echo '<br><b>action:</b><br>';

        if ( isset( p::$name_action [$name] ['page'] ) )
        {
            echo 'Страницы<br>'; 
            foreach ( p::$name_action [$name] ['page']  as $id => $name)
            {
                echo '<a href="index.php?p='.$name.'">'.$name.'</a><br>';
            }
        }
        if ( isset ( p::$name_action [$name] ) )
        {
            print_r( p::$name_action [$name]  );
        }
        else
        {
            echo 'no';
        }   

    }
    else
    {
        echo 'ошибка';
    }

    echo '<b>Настройки</b><br>';

    $setting = get_option('plugin_setting');

    if (isset($_GET['name']) and isset($setting[$_GET['name']]) )
    {
        $setting = $setting[$_GET['name']];  

        if ( is_array($setting) and count($setting) > 0)
        {
            $f = new form(); 
            $f->class='setting_class';
            $color = '';
            foreach ($setting as $name => $value)
            {
                if ($value['type'] == 'select')
                {
                    $opt = array();

                    foreach ($value['option'] as $va)
                    {
                        $sel = '';
                        if ($va == $value['value'] ) $sel = 'selected' ;
                        $opt [] = array(
                        0=> $va,
                        1=> $va,
                        2=> $sel
                        );  
                    }

                    $color = $color == '#eee' ? '#fff':'#eee';   
                    $f->clform[] = '<tr bgcolor="'.$color.'"><td width="100px" align="center">';
                    $f->add($value['type'], '', $name,  $value['value'], '</td><td align="left">'.$value['title'].'</td></tr>', $opt);
                }

                if ($value['type'] == 'text')
                {
                    $color = $color == '#eee' ? '#fff':'#eee';   
                    $f->maxlength = 100;
                    $f->clform[] = '<tr bgcolor="'.$color.'"><td width="100px" align="center">';
                    $f->add('input', '', $name,  $value['value'], '</td><td align="left">'.$value['title'].'</td></tr>', $opt);
                }   
                // echo $value['value'].' '.$value['title'].'<br>';
            }

            echo '<table class="table_setting" width="100%" border="0" cellpadding="3">';     
            echo $f->get_form();  
            echo '</table>';     
        }  
    }   

?>



                        
</div>